Repository navigation
Detect mask hierarchy cycles before reducing direct edges - #200
Merged
Merged
Conversation
_relations removed every edge with a two-step path, which empties a dense or chorded cycle and hid the mask_hierarchy_cycle warning. Strongly connected sets are now found first: edges inside one stay direct, and the transitive reduction runs only between sets. Acyclic hierarchies are unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Scma6W3LC11s3qjXHZuGDm
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Scma6W3LC11s3qjXHZuGDm
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Scma6W3LC11s3qjXHZuGDm
This was referenced Nov 7, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #197
What changed and why
_relationsmarked an edgedirect=Falsewhenever a two-step path existed (transitive reduction), which assumes an acyclic graph. For a dense or chorded cycle every edge has such a path, soMaskReport.hierarchycame out empty, nomask_hierarchy_cyclewarning fired, and the masks looked like separate roots.Now strongly connected sets are computed on the full nested-relation graph first. Edges inside a set stay direct (so the cycle is reported by the existing detection and warning); the transitive reduction runs only between sets. For acyclic hierarchies every set is a single mask, so the direct edges are exactly as before.
mask_scan.pyis 599 lines (limit 600).Regression tests (
tests/test_mask_hierarchy_cycles.py, through_relations)test_a_complete_three_cycle_keeps_its_edges_and_warns: fails on old code, passes now.test_a_cycle_with_a_chord_keeps_its_edges_and_warns: fails on old code, passes now.test_the_reduction_runs_between_cycles_and_acyclic_edges_are_unchanged: the acyclic chain part gives the same direct edges as before; the mixed cycle-below-a-parent part fails on old code. Passes now.test_nested_hierarchy_keeps_direct_parents_onlystill passes unchanged.Checks
python tools/check.py: 3899 passed, 4 skipped (case-insensitive file system x3 files, file-mode permissions x1; skips not counted as passes), 2 warnings, code rules OK.Generated by Claude Code